﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;

namespace QLBenhVien
{
    public partial class frmBaoCao : Form
    {
        public frmBaoCao()
        {
            InitializeComponent();
        }
        private void ThemThang()
        {
            
            cb_thang.Items.Add("Chọn tháng");
            cb_thang.SelectedIndex = 0;
            for (int i = 1; i <= 12; i++)
            {
                cb_thang.Items.Add(i.ToString());
            }
        }
        private void ThemNam()
        {
            int nam = DateTime.Now.Year;
            cb_nam.Items.Add("Chọn năm");
            cb_nam.SelectedIndex = 0;
            for (int i = 1990; i <= nam; i++)
            {
                cb_nam.Items.Add(i.ToString());
            }
        }

        private void frmBaoCao_Load(object sender, EventArgs e)
        {
            ThemThang();
            ThemNam();
        }

        private void cmd_xem_Click(object sender, EventArgs e)
        {
            if (cb_thang.SelectedIndex != 0)
            {
                if (cb_nam.SelectedIndex == 0)
                {
                    MessageBox.Show("Vui lòng chọn năm");
                    cb_nam.Focus();
                    return;
                }
                else
                {
                    DataTable Kq = DAOBaoCao.getMonth((string)cb_thang.SelectedItem,(string)cb_nam.SelectedItem);
                    crystalReportViewer1.ReportSource = Kq;
                    crystalReportViewer1.Refresh();                    
                }
            }
        }
    }
}
